__author__ = 'Administrator'

path = "C:\\Users\\Administrator.WIN7U-20130708F\\Desktop\\pyts.txt"

f = open(path, 'r', encoding="utf-8")

for line in f:
    print(line, end='')

f.close()

f = open(path, 'w', encoding="utf-8")
f.write('This is a test\n')

value = ('the answer', 42)
s = str(value)
f.write(s)
f.close()

f = open(path, 'r+', encoding="utf-8")
f.write('0123456789abcdef')
print(f.seek(5))  # Go to the 6th byte in the file
print(f.read(1))

# print(f.seek(-3, 2))  # Go to the 3rd byte before the end
print(f.read(1))
f.close()

with open(path, 'r') as f:
    read_data = f.read()
print(f.closed)
